package com.zy.design.pattern.observer;

import com.zy.design.pattern.observer.guava.DisObserverByEventBus;
import com.zy.design.pattern.observer.guava.LogObserverByEventBus;
import com.zy.design.pattern.observer.guava.LoginObservableByEventBus;
import com.zy.design.pattern.observer.syn.DiscountObserver;
import com.zy.design.pattern.observer.syn.LoginObservable;

/**
 * @author zhaoyi
 * @date 2021/4/25 14:02
 */
public class Test {
    public static void main(String[] args) {
        LoginObservable login = new LoginObservable();
        //注册发优惠券的观察者
        login.add(new DiscountObserver());

        login.login("1", "11");
        login.login("2", "22");
        login.login("", "");

        System.out.println("---------------------------------------------------------");

        LoginObservableByEventBus login2 = new LoginObservableByEventBus();
        login2.add(new DisObserverByEventBus());
        login2.add(new LogObserverByEventBus());

        login2.login("111", "111");
        login2.login("22", "222");
        login.login("", "333");

        System.exit(0);


    }
}
